home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 33.asm < prev    next >
Assembly Source File  |  1999-09-06  |  2KB  |  61 lines

  1. * 33.asm    Demonstrate TLtsize        version 0.01  8.6.99
  2.  
  3.  
  4.  include 'Front.i'        ;*** change to 'Tandem.i to step thru TL's ***
  5.  
  6.  
  7. ; This program introduces TLTsize, which gets text size without actually
  8. ; printing it. This is useful for making your programs font sensitive.
  9. ; The program below allows for the window to be resized. This will be
  10. ; covered in a more rigorous fashion in later examples.
  11.  
  12.  
  13. strings: dc.b 0
  14. st_1: dc.b 'Test TLTsize',0 ;1
  15.  dc.b 'This text is to appear at the bottom right',0 ;2
  16.  dc.b 'This text is to be spread out',0 ;3
  17.  dc.b '(Click the close window gadget)',0 ;4
  18.  
  19.  ds.w 0
  20.  
  21.  
  22. * sample program
  23. Program:
  24.  TLwindow #0,#0,#0,#400,#150,#640,#200,#0,#st_1
  25.  beq.s Pr_quit
  26.  bsr Test                  ;do test of TLtsize,&c
  27. Pr_quit:
  28.  rts
  29.  
  30. * test TLTsize
  31. Test:
  32.  move.l xxp_AcWind(a4),a5  ;a5 = the currently popped window
  33.  move.w #$0100,xxp_FrontPen(a5) ;pens 1,0
  34.  
  35.  TLreqcls                  ;clear window, call TLwupdate
  36.  
  37.  TLstrbuf #2               ;string 2 to buff
  38.  TLtsize                   ;get string size
  39.  
  40.  moveq #0,d2               ;calculate rightmost posn printable
  41.  move.w xxp_PWidth(a5),d2  ;(use D2 since TLwcheck changes D0)
  42.  sub.l d4,d2               ;D2=rightmost printable
  43.  moveq #0,d1               ;calculate botmost posn printable
  44.  move.w xxp_PHeight(a5),d1
  45.  sub.w d6,d1               ;D1=botmost posn printable
  46.  
  47.  TLtrim d2,d1              ;print the text at the bot right
  48.  move.w #8,xxp_Tspc(a5)    ;set inter-chr spc to 8 (normally 0)
  49.  TLstring #3,#10,#19       ;print string 3 at 10,19 (spread out)
  50.  clr.w xxp_Tspc(a5)        ;inter-chr spc back to 0
  51.  move.b #2,xxp_FrontPen(a5) ;colour 2 to highlight string 4
  52.  TLstring #4,#4,#29        ;print string 4 at 4,29 (not spread out)
  53.  
  54. Te_wait:
  55.  TLwcheck                  ;go redraw if window resized
  56.  bne Test
  57.  TLkeyboard                ;wait for close gadget
  58.  cmp.w #$93,d0
  59.  bne Te_wait
  60.  rts
  61.